<template>
  <div class="reportMistakeInfoAction el-card is-always-shadow el-card__body">
    <avue-crud
      ref="crud"
      :option="option"
      :table-loading="listLoading"
      :data="tableData"
      :permission="permissionList"
      :page.sync="page"
      :search.sync="searchForm"
      :row-style="rowStyle"
      @search-change="handleFilter"
      @selection-change="selectionChange"
      @refresh-change="refreshChange"
      @on-load="refreshChange">
      <template slot="menuRight">
        <el-button type="primary" size="mini" @click="addContent('添加',0)">添加</el-button>
        <el-button type="primary" size="mini" @click="delData()">删除</el-button>
        <el-button type="primary" size="mini" v-permission="permissionList.highDelData" @click="highDelData()">
          高级删除
        </el-button>
        <el-button type="primary" size="mini" @click="noticeReport">通知</el-button>
        <el-button type="primary" size="mini" @click="noticeReportRepeat">超期重新发通知</el-button>
        <!--        <el-upload-->
        <!--          class="upload-inline"-->
        <!--          action=""-->
        <!--          :show-file-list="false"-->
        <!--          accept=".xls,.xlsx"-->
        <!--          :on-change="handleChange">-->
        <!--          <el-button type="primary" size="mini">导入</el-button>-->
        <!--        </el-upload>-->
        <!-- <Export style="display: inline-flex;padding: 0px;width: auto;" @importSuccess="search"></Export> -->
        <Export style="display: none;padding: 0px;width: auto;" @importSuccess="search"></Export>
        <el-button type="primary" size="mini" @click="addModifyLimitTime()">设定期限</el-button>
        <!--<el-button type="primary" size="mini" @click="uploadXlsx">导入</el-button>-->
        <el-button type="primary" size="mini" @click="templateDownload" hidden>导入模板下载</el-button>
        <el-button type="primary" size="mini" @click="exportdata">导出</el-button>
      </template>
      <template slot-scope="scope" slot="lineNameSearch">
        <el-select v-model="searchForm.lineCode" placeholder="请选择" style="width: 150px" @change="changeLine">
          <el-option
            v-for="(item,index) in lineCodes"
            :key="index"
            :label="item.name"
            :value="item.code">
          </el-option>
        </el-select>
      </template>
      <template slot-scope="scope" slot="stationNameSearch">
        <el-select v-model="searchForm.stationCode" placeholder="请选择" style="width: 150px">
          <el-option
            v-for="(item,index) in stationCodes"
            :key="index"
            :label="item.name"
            :value="item.code">
          </el-option>
        </el-select>
      </template>
      <template slot="search" slot-scope="{row,size}">
        <el-form-item label="通知时间">
          <el-date-picker
            :size="size"
            v-model="searchForm.noticeTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="通知时间">
          </el-date-picker>
        </el-form-item>
        <!--        <el-form-item label="报表时间">-->
        <!--          <el-date-picker-->
        <!--            :size="size"-->
        <!--            v-model="searchForm.reprotTime"-->
        <!--            type="date"-->
        <!--            value-format="yyyy-MM-dd"-->
        <!--            placeholder="报表时间">-->
        <!--          </el-date-picker>-->
        <!--        </el-form-item>-->
        <el-form-item label="修改状态">
          <el-select
            :size="size"
            v-model="searchForm.isModify"
            type="select"
            placeholder="修改状态">
            <el-option value="1" label="已完成"></el-option>
            <el-option value="0" label="待修改"></el-option>
          </el-select>
        </el-form-item>
      </template>
      <template slot-scope="scope" slot="reportNameSearch">
        <el-select v-model="searchForm.reportNameId" placeholder="请选择" style="width: 150px">
          <el-option
            v-for="(item,index) in reportNameIds"
            :key="index"
            :label="item.reportName"
            :value="item.id">
          </el-option>
        </el-select>
      </template>
      <template slot="searchMenu" slot-scope="{row,size}">
        <el-button :size="size" @click="()=>{setSearchFiledsEmpty(row);setSearchFiledsEmpty(searchForm);search()}"
                   icon="el-icon-delete">清空
        </el-button>
      </template>
      <template slot-scope="scope" slot="menu">
        <el-button type="text" size="small" plain @click.stop="previewEditor(scope.row,1,'预览')">预览</el-button>
        <el-button type="text" size="small" v-if="scope.row.noticeStatus == 1 && scope.row.isModify == 1" plain @click.stop="getInfo(scope.row)">报表跳转</el-button>
        <el-button type="text"
                   v-if="(!scope.row.noticeStatus || scope.row.noticeStatus=='0') && scope.row.dataSource!=1"
                   size="small" plain @click.stop="editorContent(scope.row,2,'编辑')">编辑
        </el-button>
      </template>
    </avue-crud>
    <report-mistake-info-editor ref="reportMistakeInfoEditor"
                                v-if="isShowReportMistakeInfoEditor"></report-mistake-info-editor>
    <report-mistake-info-preview ref="reportMistakeInfoPreview"
                                 v-if="isShowReportMistakeInfoPreview"></report-mistake-info-preview>
    <add-modify-limit-time-vue v-if="addModifyLimitTimeVisible" ref="addModifyLimitTimeVue"></add-modify-limit-time-vue>
  </div>
</template>


<script>
import {getForm, postForm} from '@/api/gen/gen'
// import reportMistakeInfoEditor from './reportMistakeInfo/reportMistakeInfoEditor';
import {dateFormat} from '@/util/date';
import AddModifyLimitTimeVue from './addModifyLimitTimeVue';
import reportMistakeInfoEditor from './reportMistakeInfo/Editor';
import reportMistakeInfoPreview from './reportMistakeInfo/reportMistakeInfoPreview';
import ExportJsonExcel from "js-export-excel";
import moment from 'moment';
import {
  delReportError,
  highDelReportError,
  getLineLists,
  getReportErrorList, getReports,
  getStationLists, noticeReport, checkXlsxData
} from "../../../api/subwayRat/reportMondify/reportMistakeInfo";
import {
  getgetStationCodes,
  getLineCodes, getStationByCode, getLineAndStationByCode, setSearchFiledsEmpty, getMappingStatus
} from "../../../api/subwayRat/commonCheck";
import Export from './reportMistakeInfo/Export';
import {exportDataToExcel} from "../../../api/subwayRat/exportSelf";
import {mapGetters} from 'vuex'
import {get_month_first, get_month_last} from "@/const/crud/rca/common";

export const startDate = get_month_first(0);
export const endDate = get_month_last(0);
export default {
  components: {
    reportMistakeInfoEditor, reportMistakeInfoPreview, AddModifyLimitTimeVue, Export
  },
  data() {
    return {
      row: {},
      listLoading: true,
      fileTemp: {},
      searchForm: {
        reportType: 2,
        lineCode: '9',
        stationCode: '',
        noticeStatus: '0'
      },
      tableData: [],
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        current: 1,// 当前页数
        pageSize: 20, // 每页显示多少条,
        size: 20,// 每页显示多少条
        isAsc: false// 是否倒序
      },
      autoWidth: true,
      downloadLoading: false,
      isShowReportMistakeInfoEditor: false,//是否加载编辑页面
      isShowReportMistakeInfoPreview: false,//是否加载预览页面
      multipleSelectionRows: [],
      multipleSelectionKeys: [],
      lineCodes: [],
      stationCodes: [],
      reportNameIds: [],
      addModifyLimitTimeVisible: false,
      param: {
        lineCode: "",
        stationCode: '',
        reprotTime: "",
        reportNameId: "",
        settleBeginTime: "",
        settleEndTime: "",
        noticeTime: "",
        isModify: ""
      },
      option: {
        emptyBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        border: true,
        index: true,
        indexLabel: '序号',
        page: true,
        align: 'center',
        menuWidth: 150,
        menuAlign: 'center',
        selection: true,
        reserveSelection: false,
	height: 500,
        column: [
          {prop: "lineName", width: 100, hide: true, label: "线路", type: 'select', search: false, searchslot: true},
          {prop: "stationName", width: 120, label: "站点", search: true, searchslot: true},
          {
            prop: "reprotTime",
            width: 120,
            label: "报表时间",
            type: 'datetime',
            format: 'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd'
          },
          {prop: "reportName", width: 200, label: "报表名称", search: true, searchslot: true},
          // {prop:"stationPersonName", label:"站务员"},
          {prop: 'stationPersonrName', width: 120, label: "涉及人员"},
	  {prop:"dutyStationLeaderName", label:"值班站长"},
          {prop:"dutyStationLeaderCode" ,label:"值班站长工号"},
          {
            prop: "isModify", width: 120, label: "修改状态",
            dicData: [{
              label: '待修改',
              value: '0'
            }, {
              label: '已完成',
              value: '1'
            }],
            formatter: function (row, value, label, column) {
              return value == 1 ? '已完成' : value == 0 ? '待修改' : '';
            }
          },
          {
            prop: "noticeTime",
            width: 120,
            label: "通知时间",
            type: 'datetime',
            format: 'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd'
          },
          {prop: "applyReason", label: "申请原因", width: 160},
          {
            prop: "applyTime",
            width: 160,
            label: "申请时间",
            type: 'datetime',
            format: 'yyyy-MM-dd HH:mm:ss',
            valueFormat: 'yyyy-MM-dd HH:mm:ss'
          },
          {
            prop: "dates1",
            width: 120,
            label: "报表时间",
            type: 'date',
            format: 'yyyy-MM-dd',
            hide: true,
            valueFormat: 'yyyy-MM-dd',
            search: true,
            searchRange: true,
            searchSpan: 12
          },
          {
            prop: "modifyTime",
            width: 120,
            label: "实际更改日期",
            type: 'datetime',
            format: 'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd'
          },
          {
            prop: "errorClassification", label: "差错类别", search: 'true', type: 'select',
            dicUrl: '/admin/dict/type/ERROR_CLASSIFICATION',
            formatter: function (row, v) {
              return getMappingStatus('ERROR_CLASSIFICATION', v);
            }
          },
          {prop: "remark", label: "备注", width: 150},
          {
            prop: "source", width: 120, label: "来源", search: 'true', type: 'select',
            dicData: [{
              label: '车站申请',
              value: '1'
            }, {
              label: '线路下发',
              value: '2'
            }],
            formatter: function (row, value, label, column) {
              return value == "1" ? '车站申请' : '线路下发';
            }
          },
          {
            prop: "dataSource", width: 240, label: "差错来源", search: 'true', type: 'select',
            dicUrl: '/admin/dict/type/report_error_data_source',
            formatter: function (row, v) {
              return getMappingStatus('report_error_data_source', v);
            }
            // dicData: [{
            //   label: '车站申请',
            //   value: '1'
            // }, {
            //   label: '线路手工录入',
            //   value: '2'
            // },{
            //   label: '售票员票款差异',
            //   value: '3'
            // },{
            //   label: 'TVM票款差异',
            //   value: '4'
            // },{
            //   label: '分钱箱票款差异',
            //   value: '5'
            // },{
            //   label: '乘客事务审核',
            //   value: '6'
            // },{
            //   label: '乘客事务-其他相关数据录入',
            //   value: '7'
            // },{
            //   label: '乘客事务审核（即时退换票）',
            //   value: '8'
            // },{
            //   label: '乘客事务审核（非即时退换票）',
            //   value: '9'
            // },{
            //   label: '营销车票审核',
            //   value: '10'
            // },{
            //   label: '票卡信息审核差异',
            //   value: '11'
            // },{
            //   label: '互联网售票机',
            //   value: '12'
            // }]
          },
          {prop: "modifyLimitTime", width: 120, label: "修改期限（天）"},
          //{prop: "stationPersonrName", width: 120, label: "更改人"},
          {prop: "noticePerson", label: "通知人", width: 100},
          {prop: "noticePersonCode", label: "通知人工号", width: 100, hide: true},
          {
            prop: "noticeStatus", width: 120, label: "通知状态", search: 'true', searchValue: '0', type: 'select',
            dicUrl: '/admin/dict/type/report_error_notice_status',
            formatter: function (row, v) {
              return getMappingStatus('report_error_notice_status', v);
            }
          }
        ]
      },
    }
  },
  computed: {
    ...mapGetters(['permissions']),
    permissionList() {
      return {
        highDelData: this.vaildData(
          this.permissions.sw_st_report_error_alter_apply_highdel,
          false
        ),
      };
    }
  },
  created() {
    this.changeLine("9")
    if (this.$route.query.row) {
      this.row = this.$route.query.row;
      // debugger
      if (!this.row.submitLineCode && !this.row.submitStationCode) {
        this.row.submitLineCode = this.row.lineCode;
        this.row.submitStationCode = this.row.stationCode;
      }
      this.addContent('添加', 0, 3);
    }
  },
  methods: {
    setSearchFiledsEmpty,
    refreshChange() {
      this.search()

    },

    //超出最大上传文件数量时的处理方法
    handleExceed() {
      this.$message({
        type: 'warning',
        message: '超出最大上传文件数量的限制！'
      })
      return;
    },
    handlePreview(file) {
      alert("successFun")
    },
    templateDownload() {
      let option = {};
      option.fileName = "报表差错信息";
      let header = ["lineName", "stationName", "noticeTime", "reprotTime", "reportName", "stationPersonrName", "remark", "isModify", "dataSource", "modifyTime", "creatorName"];
      let headername = ["线路", "站点", "通知时间", "报表时间", "报表名称", "涉及人员", "备注", "修改状态", "数据来源", "更改日期", "更改人"];
      let allData = [];
      option.datas = [
        {
          sheetData: allData,
          sheetName: 'sheet',
          sheetFilter: header,
          sheetHeader: headername,
        }
      ];
      let toExcel = new ExportJsonExcel(option); //new
      toExcel.saveExcel();
    },

    search() {
      this.listLoading = true;
      this.searchForm.pageType = 1;
      this.searchForm.checkStatus = 3;
      this.page.size = this.page.pageSize;
      this.page.current = this.page.currentPage;
      Object.assign(this.searchForm, this.page);
      this.searchForm.userCode = this.$store.getters.userInfo.userCode;
      this.searchForm.reportType = 2;
      //日期范围
      let dates1 = this.searchForm.dates1;
      if (dates1 != null && dates1 != '') {
        this.searchForm.startdate = dates1[0].substr(0, 10);
        this.searchForm.enddate = dates1[1].substr(0, 10);
      }
      getReportErrorList(this.searchForm).then((res) => {
        this.tableData = res.data.data.records;
        this.listLoading = false;
        this.page.total = res.data.data.total;
      });
    },
    delData() {
      if (this.multipleSelectionKeys.length <= 0) {
        this.$message({
          message: '请选择操作项！',
          type: 'warning'
        });
        return;
      }
      for (let i = 0; i < this.multipleSelectionRows.length; i++) {
        if (this.multipleSelectionRows[i].dataSource == 1) {
          this.$message.warning("车站数据不允许删除！");
          return;
        }
        if (this.multipleSelectionRows[i].noticeStatus == 1) {
          this.$message.warning("已通知数据不允许删除！");
          return;
        }
      }
      this.$confirm('您是否要删除此数据？', '提示', {
        confirmButtonText: '是',
        cancelButtonText: '否',
        type: 'warning'
      }).then(() => {
        delReportError({ids: this.multipleSelectionKeys.join(","), delFlag: 1}).then((res) => {
          this.$message({
            message: res.data.code == 0 ? '操作成功' : '操作失败',
            type: res.data.code == 0 ? 'success' : 'error',
          });
          this.search();
        });
      }).catch(() => {
      });
    },
    highDelData() {
      if (this.multipleSelectionKeys.length <= 0) {
        this.$message({
          message: '请选择操作项！',
          type: 'warning'
        });
        return;
      }
      this.$confirm('您是否要删除此数据？', '提示', {
        confirmButtonText: '是',
        cancelButtonText: '否',
        type: 'warning'
      }).then(() => {
        highDelReportError({ids: this.multipleSelectionKeys.join(","), delFlag: 1}).then((res) => {
          this.$message({
            message: res.data.code == 0 ? '操作成功' : '操作失败',
            type: res.data.code == 0 ? 'success' : 'error',
          });
          this.search();
        });
      }).catch(() => {
      });
    },
    addContent(title, showType, reportName) {
      this.isShowReportMistakeInfoEditor = true;
      this.$nextTick(() => {
        this.$refs.reportMistakeInfoEditor.dialogTitle = title;
        this.$refs.reportMistakeInfoEditor.clearParam();
        this.$refs.reportMistakeInfoEditor.previewEditor({}, 3, "添加");
        // if(this.row){
        //   this.$refs.reportMistakeInfoEditor.previewEditor(this.row);
        //   this.$refs.reportMistakeInfoEditor.param.lineCode = this.row.submitLineCode;
        //   this.$refs.reportMistakeInfoEditor.param.stationCode = this.row.submitStationCode;
        //   //手动调用改变车站的函数
        //   this.$refs.reportMistakeInfoEditor.changeStationCode(this.row.stationCode);
        //   this.$refs.reportMistakeInfoEditor.param.reprotTime=this.row.workDate;
        //   this.$refs.reportMistakeInfoEditor.param.reportNameId=reportName;
        //   // this.$refs.reportMistakeInfoEditor.param.reprotTime = moment();
        // }
      });
    },
    addContentCKSW(title, showType) { //乘客事务过来的
      this.isShowReportMistakeInfoEditor = true;
      this.$nextTick(() => {
        this.$refs.reportMistakeInfoEditor.showType = 0;
        this.$refs.reportMistakeInfoEditor.dialogTitle = title;
        this.$refs.reportMistakeInfoEditor.clearParam();
        if (this.row) {
          this.$refs.reportMistakeInfoEditor.previewEditor(this.row);
          this.$refs.reportMistakeInfoEditor.param.lineCode = this.row.submitLineCode;
          this.$refs.reportMistakeInfoEditor.param.stationCode = this.row.submitStationCode;
          // this.$refs.reportMistakeInfoEditor.param.reprotTime = moment();
        }
      });
    },
    getInfo(row){
      let feedbackPath = ''
      if (row.reportNameId == 1) {
        feedbackPath = '/subwayRat/conductorDifferences/conductorTicketChaYiShenhe/conductorTicketChaYiShenhe';
      } else if (row.reportNameId == 2) {
        row.pathType = 1;
        feedbackPath = '/subwayRat/conductorDifferences/passengersTransaction/passengersTransactionAudit/swStInputPassengerWork';
      } else if (row.reportNameId == 3) {
        row.pathType = 1;
        feedbackPath = '/subwayRat/conductorDifferences/passengersTransaction/passengersTransactionAudit/swStInputPassengerWork';
      } else if (row.reportNameId == 5) {
        if (row.cashboxType == '' || row.cashboxType == null) {
          feedbackPath = '/subwayRat/TVMRevenueVarianceAudit/differencesInAudit/fareDifferencesInAudit';
        } else {
          row.pathType = 1;
          feedbackPath = '/subwayRat/TVMRevenueVarianceAudit/cashBoxBatchAudit/index';
        }
      } else if (row.reportNameId == 6) {
        feedbackPath = '/subwayRat/TVMRevenueVarianceAudit/differencesInAudit/fareDifferencesInAudit';
      } else if (row.reportNameId == 7) {
        feedbackPath = '/subwayRat/TVMRevenueVarianceAudit/differencesInAudit/fareDifferencesInAudit';
      } else if (row.reportNameId == 9) {
        feedbackPath = '/subwayRat/conductorDifferences/passengersTransaction/passengersTransactionAudit/swStInputPassengerWork';
      } else if (row.reportNameId == 10) {
        feedbackPath = '/subwayRat/conductorDifferences/passengersTransaction/passengersTransactionAudit/swStInputPassengerWork';
      } else if (row.reportNameId == 11) {
        feedbackPath = '/subwayRat/conductorDifferences/conductorTicketChaYiShenhe/conductorTicketChaYiShenhe';
      }
      // else if (row.reportNameId == 12) {
      //   feedbackPath = '/subwayst/sw-tk-stock-audit/index';
      // } else if (row.reportNameId == 14) {
      //   feedbackPath = '/subwayst/sw-st-ticket-check-audit/index';
      // }
      this.$router.push({path: feedbackPath, query: row});
    },
    previewEditor(row, showType, title) {
      this.isShowReportMistakeInfoEditor = true;
      this.$nextTick(() => {
        // this.$refs.reportMistakeInfoEditor.showType=1;
        // this.$refs.reportMistakeInfoEditor.dialogTitle=title;
        this.$refs.reportMistakeInfoEditor.previewEditor(row, 1, "预览");
      });

    },
    editorContent(row, showType, title) {
      this.isShowReportMistakeInfoEditor = true;
      this.$nextTick(() => {
        // this.$refs.reportMistakeInfoEditor.showType=2;
        // this.$refs.reportMistakeInfoEditor.dialogTitle=title;
        this.$refs.reportMistakeInfoEditor.previewEditor(row, 2, '编辑');
      });
    },
    handleSelectionChange(val, a) {
      this.multipleSelectionRows = val;
      this.multipleSelectionKeys = [];
      for (let i = 0; i < this.multipleSelectionRows.length; i++) {
        this.multipleSelectionKeys.push(this.multipleSelectionRows[i].id);
      }
    },
    initLine() {
      getLineCodes().then(res => { //获取线路
        this.lineCodes = res;
      });
    },
    initReportNameIds() {
      getReports({}).then((res) => {
        this.reportNameIds = res.data.data;
      })
    },
    changeLine(v) {
      getgetStationCodes(v).then(res => {
        this.stationCodes = res;
        this.searchForm.stationCode = '';
      })
    },
    async noticeReport() {
      if (this.multipleSelectionKeys.length <= 0) {
        this.$message({
          message: '您至少选择一条或多条信息发送通知！',
          type: 'warning'
        });
        return;
      }
      let messageLSList = [];
      for (let i = 0; i < this.multipleSelectionRows.length; i++) {
        if (this.multipleSelectionRows[i].noticeStatus == '1') {
          this.$message({
            message: '选择的数据中有已经通知的记录！',
            type: 'warning'
          });
          return;
        }
        let data = await getLineAndStationByCode({
          "lineCode": this.multipleSelectionRows[i].lineCode,
          "code": this.multipleSelectionRows[i].stationCode
        });
        messageLSList.push({
          "content": "站点：" + data.data[0].name,
          "lineCode": this.multipleSelectionRows[i].lineCode,
          "stationCode": this.multipleSelectionRows[i].stationCode,
          "applyTime": this.multipleSelectionRows[i].applyTime
        })
      }
      let p = {
        messageLSList: JSON.stringify(messageLSList),
        title: this.$store.getters.tag.label,
        msgType: "通知",
        type: "reportMistakeInfo_001",
        ids: JSON.stringify(this.multipleSelectionKeys),
        noticeStatus: 1
      };
      this.$confirm('您是否要通知此数据？', '提示', {
        confirmButtonText: '是',
        cancelButtonText: '否',
        type: 'warning'
      }).then(() => {
        noticeReport(p).then((res) => {
          this.$message({
            message: res.data.code == 0 ? '操作成功' : '操作失败',
            type: res.data.code == 0 ? 'success' : 'error',
          });
          this.search();
        });
      }).catch(() => {
      });
    },
    //超期重新发通知
    async noticeReportRepeat() {
      if (this.multipleSelectionKeys.length <= 0) {
        this.$message({
          message: '您至少选择一条或多条信息发送通知！',
          type: 'warning'
        });
        return;
      }
      let messageLSList = [];
      for (let i = 0; i < this.multipleSelectionRows.length; i++) {
        if (this.multipleSelectionRows[i].noticeStatus == '0') {
          this.$message({
            message: '选择的数据中有未通知的记录！',
            type: 'warning'
          });
          return;
        }
        let data = await getLineAndStationByCode({
          "lineCode": this.multipleSelectionRows[i].lineCode,
          "code": this.multipleSelectionRows[i].stationCode
        });
        messageLSList.push({
          "content": "站点：" + data.data[0].name,
          "lineCode": this.multipleSelectionRows[i].lineCode,
          "stationCode": this.multipleSelectionRows[i].stationCode,
          "applyTime": this.multipleSelectionRows[i].applyTime
        })
      }
      let p = {
        messageLSList: JSON.stringify(messageLSList),
        title: this.$store.getters.tag.label,
        msgType: "通知",
        type: "reportMistakeInfo_001",
        ids: JSON.stringify(this.multipleSelectionKeys),
        noticeStatus: 1
      };
      this.$confirm('您是否要再次通知此数据？', '提示', {
        confirmButtonText: '是',
        cancelButtonText: '否',
        type: 'warning'
      }).then(() => {
        noticeReport(p).then((res) => {
          this.$message({
            message: res.data.code == 0 ? '操作成功' : '操作失败',
            type: res.data.code == 0 ? 'success' : 'error',
          });
          this.search();
        });
      }).catch(() => {
      });
    },
    //超期未完成的用特殊颜色表示
    rowStyle({row, column, rowIndex}) {
      let now = dateFormat(new Date()).substr(0, 10);
      if (row.noticeTime != null && row.noticeTime != '' && row.isModify == '0') {
        let lastTime = moment(row.noticeTime).add(Number(row.modifyLimitTime), 'days').format('YYYY-MM-DD');
        if (lastTime < now) {
          return {
            backgroundColor: "#eee",
            color: "red",
          };
        }
      }

    },
    async exportdata() {
      // if(this.multipleSelectionKeys.length<=0){
      //   this.$message({
      //     message: '您至少选择一条或多条信息导出！',
      //     type: 'warning'
      //   });
      //   return;
      // }
      this.searchForm.pageNo = 1;
      this.searchForm.pageSize = 1000000000;
      this.searchForm.size = 1000000000;
      if (this.multipleSelectionRows.length > 0) {
        let newData = JSON.parse(JSON.stringify(this.multipleSelectionRows));
        exportDataToExcel(newData, this.option.column, '报表差错信息');
      } else {
        let res = await getReportErrorList(this.searchForm);
        let data = res.data.data.records;
        exportDataToExcel(data, this.option.column, '报表差错信息');
      }
      // let option = {};
      // option.fileName="报表差错信息";
      // let header=["id","lineName","stationName","noticeTime","reprotTime","reportName","stationPersonrName","remark","isModify","dataSource","modifyTime","creatorName"];
      // let headername=["序号","线路","站点","通知时间","报表时间","报表名称","涉及人员","备注","修改状态","数据来源","更改日期","更改人"];
      // let allData=[];
      // for(let i=0;i<this.tableData.length;i++){
      //   if(this.tableData[i].isModify=='0'){
      //     this.tableData[i].isModify='未完成';
      //   }else if(this.tableData[i].isModify=='1'){
      //     this.tableData[i].isModify='已完成';
      //   }else if(this.tableData[i].isModify=='2'){
      //     this.tableData[i].isModify='修改中';
      //   }
      //   allData.push(this.tableData[i]);
      // }
      // if(this.multipleSelectionKeys.length>0){
      //   allData=this.multipleSelectionRows;
      // }
      // option.datas = [
      //   {
      //     sheetData: allData,
      //     sheetName: 'sheet',
      //     sheetFilter: header,
      //     sheetHeader: headername,
      //   }
      // ];
      // let toExcel = new ExportJsonExcel(option); //new
      // toExcel.saveExcel();
    },
    selectionChange(list) {
      this.multipleSelectionRows = list;
      this.multipleSelectionKeys = [];
      for (let i = 0; i < list.length; i++) {
        this.multipleSelectionKeys.push(list[i].id);
      }
    },
    handleFilter(params, done) {
      Object.assign(this.searchForm, params);
      this.search()
      done()
    },
    addModifyLimitTime() {
      if (this.multipleSelectionRows.length == 0) {
        this.$message({message: '请勾选数据后设定期限', type: 'warning'});
        return;
      }
      this.addModifyLimitTimeVisible = true;
      this.$nextTick(() => {
        this.$refs.addModifyLimitTimeVue.checkData = this.multipleSelectionRows;
      });
    },
  },
  mounted() {
    this.search();
    this.initLine();
    this.initReportNameIds();
  }
}
</script>
<style lang="scss">

</style>
